package vip.george.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import vip.george.bean.animal.Dog;
import vip.george.bean.config.ProxyConfig;


public class App32 {

    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ProxyConfig.class);
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }

        System.out.println("--------------");
        ProxyConfig proxyConfig = applicationContext.getBean("proxyConfig", ProxyConfig.class);
        System.out.println(proxyConfig);
        System.out.println("--------------");

        // 如果proxyConfig配置类的注解改为@Configuration(proxyBeanMethods = false)，则下面会生成三个全新的Mouse对象
        // 否则，只生成一个Mouse对象,第二次和第三次调用这个方法，会返回已经存在的Mouse对象
        System.out.println(proxyConfig.getMouse());
        System.out.println(proxyConfig.getMouse());
        System.out.println(proxyConfig.getMouse());


    }
}
